import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { user } from '@/types/user'

export const useUserStore = defineStore(
  'modical_user',
  () => {
    // 1. 定义用户数据
    const user = ref<user>()
    // 2. 定义新增
    const setUser = (u: user) => {
      user.value = u
    }
    // 3. 删除
    const delUser = () => {
      user.value = undefined
    }
    return {
      user,
      setUser,
      delUser
    }
  },
  { persist: true }
)
